
$(function(){
    //var newTarget=$(".content.new");
    //var hotTarget=$(".content.hot");
    //var newArticlePanel=$(".new .ArticlePanel");
    //var hotArticlePanel=$(".hot .ArticlePanel");
    //newTarget.click(toNew);
    //hotTarget.click(toHot);
    //function toNew(){
    //    newTarget.css({width:"66%"});
    //    hotTarget.css({width:"26%",left:"72%"});
    //    newArticlePanel.css({"min-height":"300px","max-height":"500px"});
    //    hotArticlePanel.css({"min-height":"150px","max-height":"200px"});
    //}
    //function toHot(){
    //    newTarget.css({width:"26%"});
    //    hotTarget.css({width:"66%",left:"32%"});
    //    newArticlePanel.css({"min-height":"150px","max-height":"200px"});
    //    hotArticlePanel.css({"min-height":"300px","max-height":"500px"});
    //}

});

!function(){
    var pageHot=1;
    $(function(){
        $(window).scroll(function () {
            if($(window).height() + $(window).scrollTop()>=document.scrollingElement.scrollHeight&&$(window).scrollTop()>0){
                var hot=$(".hot .ArticlePanel");
                if(hot.length!=0&&hot.length%30==0){
                    $.post("/getHotArticle",{page:++pageHot},function(o){
                        if(o){
                            setHot(JSON.parse(o));
                        }
                    })
                }
            }
        });
    });
    var model=$(".ArticlePanel.scrollbar.model");
    function setArticle(temp){
        var time=new Date(temp.createTime).toLocaleString();
        var tempCare=model.clone();
        tempCare.find(".authorPhoto").attr("src",temp.user.photo?temp.user.photo:"photo/0.png")
        tempCare.find(".author").attr("href","user"+temp.user.id);
        tempCare.find(".author").text(temp.user.nickName?temp.user.nickName:temp.user.name);
        tempCare.find(".createTime").text("发表时间："+time);
        tempCare.find(".ck").text("查看"+temp.click);
        tempCare.find(".title.at").attr("href","Article"+temp.id);
        tempCare.find(".title.at").text(temp.name);
        tempCare.find(".ArticleContent").html(temp.content);
        tempCare.css("display","block");
        return tempCare;
    }
    function setHot(js){
        for(var i=0;i<js.length;++i){
            $(".content.hot").append(setArticle(js[i]));
        }
    }
}();


